import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
  DefaultValuePipe,
  ParseIntPipe,
  Req,
  UseGuards,
} from '@nestjs/common';
import { OutboundplanService } from 'src/service/outboundplan.service';
import { CreateOutboundplanDto } from 'src/dto/create-outboundplan.dto';
import { UpdateOutboundplanDto } from 'src/dto/update-outboundplan.dto';
import { QueryOutboundplanDto } from 'src/dto/query-outboundplan.dto';
import { AdminGuard } from 'src/guards/admin.guard';
import { QueryWarehouseProductSkuDto } from 'src/dto/query-getProductAndSku.dto';

@UseGuards(AdminGuard)
@Controller('admin/outboundplan')
export class OutboundplanController {
  constructor(private readonly outboundplanService: OutboundplanService) {}

  @Post()
  create(
    @Body() createOutboundplanDto: CreateOutboundplanDto,
    @Req() req: any,
  ) {
    return this.outboundplanService.create(createOutboundplanDto, req.uid);
  }

  @Post('createMix')
  createMix(
    @Body() createOutboundplanDto: CreateOutboundplanDto,
    @Req() req: any,
  ) {
    return this.outboundplanService.createMix(createOutboundplanDto, req.uid);
  }

  @Get('getProductAndSku')
  getProductAndSku(
    @Query() queryWarehouseProductSkuDto: QueryWarehouseProductSkuDto,
  ) {
    return this.outboundplanService.getProductAndSku(
      queryWarehouseProductSkuDto,
    );
  }

  @Get()
  query(@Query() query: QueryOutboundplanDto) {
    return this.outboundplanService.query(query);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.outboundplanService.findOne(+id);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateOutboundplanDto: UpdateOutboundplanDto,
    @Req() req: any,
  ) {
    return this.outboundplanService.update(+id, updateOutboundplanDto, req.uid);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.outboundplanService.remove(+id);
  }

  @Post('toShipping')
  toShipping(
    @Body('id') id: number,
    @Body('mercadoBoxNumber') mercadoBoxNumber: string,
    @Body('boxExpressNo') boxExpressNo: string,
  ) {
    return this.outboundplanService.toShipping(
      id,
      mercadoBoxNumber,
      boxExpressNo,
    );
  }

  @Post('createDeShengExcel')
  createDeShengExcel(@Body('id') id: number) {
    return this.outboundplanService.createDeShengExcel(id);
  }
}
